home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / System / MCC_SpeedBar / Developer / C / Examples / Demo.c < prev    next >
C/C++ Source or Header  |  1999-10-13  |  10KB  |  216 lines

  1. /*
  2. ** $Id: Demo.c,v 1.7 1999/09/27 18:16:52 wiz Exp $
  3. */
  4.  
  5. /// Include
  6. #include <exec/types.h>             //  exec
  7. #include <exec/libraries.h>
  8. #include <exec/memory.h>
  9. #include <dos/dos.h>                //  dos
  10. #include <libraries/mui.h>          //  libraries
  11. #include <clib/muimaster_protos.h>  //  clib
  12. #include <clib/alib_protos.h>
  13. #include <proto/exec.h>             //  proto
  14. #include <proto/dos.h>
  15. #include <proto/muimaster.h>
  16.  
  17. #include <string.h>
  18. #include <stdio.h>
  19.  
  20. #include "/SpeedBar_mcc.h"
  21. #include "/SpeedBarCfg/SpeedBarCfg_mcc.h"
  22. #include "MyBrush.h"
  23. ///
  24. /// Data
  25. struct Library *MUIMasterBase;
  26. ///
  27.  
  28.  
  29. /// MakeLabel1
  30. Object *MakeLabel1( STRPTR str )
  31. {
  32.     return( MUI_MakeObject( MUIO_Label, str, MUIO_Label_SingleFrame ));
  33. }
  34. ///
  35. /// MakeCheck
  36. Object *MakeCheck( STRPTR str )
  37. {
  38.     Object *obj = MUI_MakeObject( MUIO_Checkmark, str );
  39.  
  40.     if( obj )
  41.         set( obj, MUIA_CycleChain, TRUE );
  42.  
  43.     return( obj );
  44. }
  45. ///
  46. /// MakeCycle
  47. Object *MakeCycle( STRPTR *array, STRPTR txt )
  48. {
  49.     Object *obj = MUI_MakeObject( MUIO_Cycle, txt, array );
  50.  
  51.     if( obj )
  52.         set( obj, MUIA_CycleChain, TRUE );
  53.  
  54.     return( obj );
  55. }
  56. ///
  57.  
  58.  
  59. int main( int argc, char *argv[] )
  60. {
  61.     Object                             *AppObj, *MainWin, *SpeedBar, *SpeedBar2;
  62.     Object                             *Settings, *update;
  63.     BPTR                                olddir, lock;
  64.     static struct MUIS_SpeedBar_Button  buttons[] = {
  65.                                             { 0, "Toggle",    "Toggle mode example",      MUIV_SpeedBar_ButtonFlag_Toggle,    NULL },
  66.                                             { 1, "Immediate", "Immediate mode example",   MUIV_SpeedBar_ButtonFlag_Immediate, NULL },
  67.                                             { MUIV_SpeedBar_Spacer },
  68.                                             { 2, "Quit",      "This will quit the program", 0, NULL },
  69.                                             { 2, "Disabled",  "This does nothing at all",   MUIV_SpeedBar_ButtonFlag_Disabled, NULL },
  70.                                             { MUIV_SpeedBar_End },
  71.                                         };
  72.     static struct MUIS_SpeedBar_Button  buttons2[] = {
  73.                                             { 0, "Toggle",    "Toggle mode example",      MUIV_SpeedBar_ButtonFlag_Toggle,    NULL },
  74.                                             { 1, "Immediate", "Immediate mode example",   MUIV_SpeedBar_ButtonFlag_Immediate, NULL },
  75.                                             { MUIV_SpeedBar_Spacer },
  76.                                             { 2, "Quit",      "This will quit the program", 0, NULL },
  77.                                             { 2, "Disabled",  "This does nothing at all",   MUIV_SpeedBar_ButtonFlag_Disabled, NULL },
  78.                                             { MUIV_SpeedBar_End },
  79.                                         };
  80.     static STRPTR                       Modes[] = {
  81.                                             "Text + Graphics",
  82.                                             "Graphics only",
  83.                                             "Text only",
  84.                                             NULL
  85.                                         };
  86.     static STRPTR                       Files[] = {
  87.                                             "Pic1.iff",
  88.                                             "Pic2.iff",
  89.                                             "Pic3.iff",
  90.                                             "Spacer.iff"
  91.                                         };
  92.     ULONG                               i;
  93.     struct MyBrush                     *Brushes[4] = { 0 };
  94.  
  95.     if(!( MUIMasterBase = OpenLibrary( "muimaster.library", 19 )))
  96.         return( 20 );
  97.  
  98.     if( lock = Lock( "PROGDIR:", ACCESS_READ ))
  99.         olddir = CurrentDir( lock );
  100.  
  101.     for( i = 0; i < 4; i++ )
  102.         Brushes[ i ] = LoadBrush( Files[ i ]);
  103.  
  104.     if( AppObj = ApplicationObject,
  105.  
  106.                         MUIA_Application_Title,         "SpeedBar Test",
  107.                         MUIA_Application_Version,       "$VER: SpeedBarTest 1.1 (26.9.99)",
  108.                         MUIA_Application_Copyright,     "Copyright ©1999 by Simone Tellini",
  109.                         MUIA_Application_Author,        "Simone Tellini <wiz@vapor.com>",
  110.                         MUIA_Application_Description,   "Speed(Bar|Button|BarCfg).mcc test program",
  111.                         MUIA_Application_Base,          "SPEEDBARTEST",
  112.  
  113.                         SubWindow, MainWin = WindowObject,
  114.  
  115.                             MUIA_Window_ID,             MAKE_ID( 'M', 'A', 'I', 'N' ),
  116.                             MUIA_Window_Title,          "SpeedBarTest - ©1999 Simone Tellini",
  117.  
  118.                             WindowContents, VGroup,
  119.  
  120.                                 Child, HGroup,
  121.  
  122.                                     Child, SpeedBar = SpeedBarObject,
  123.                                         MUIA_Group_Horiz,           TRUE,
  124.                                         MUIA_SpeedBar_Images,       Brushes,
  125.                                         MUIA_SpeedBar_Borderless,   FALSE,
  126.                                         MUIA_SpeedBar_ViewMode,     MUIV_SpeedBar_ViewMode_TextGfx,
  127.                                         MUIA_SpeedBar_RaisingFrame, FALSE,
  128.                                         MUIA_SpeedBar_Buttons,      buttons,
  129.                                         MUIA_SpeedBar_SpacerIndex,  3,
  130.                                         MUIA_SpeedBar_Spread,       FALSE,
  131.                                     End,
  132.  
  133.                                     Child, HSpace( 0 ),
  134.                                 End,
  135.  
  136.                                 Child, HGroup,
  137.  
  138.                                     Child, SpeedBar2 = SpeedBarObject,
  139.                                         MUIA_SpeedBar_Images,       Brushes,
  140.                                         MUIA_SpeedBar_Borderless,   FALSE,
  141.                                         MUIA_SpeedBar_ViewMode,     MUIV_SpeedBar_ViewMode_TextGfx,
  142.                                         MUIA_SpeedBar_RaisingFrame, FALSE,
  143.                                         MUIA_SpeedBar_Buttons,      buttons2,
  144.                                         MUIA_SpeedBar_SpacerIndex,  -1,   // no image
  145.                                         MUIA_SpeedBar_Spread,       TRUE, // variable spacer size
  146.                                         MUIA_Weight,                1,    // minimum width
  147.                                     End,
  148.  
  149.                                     Child, VGroup,
  150.  
  151.                                         Child, Settings = SpeedBarCfgObject, End,
  152.                                         Child, update   = SimpleButton( "Update" ),
  153.  
  154.                                         Child, VSpace( 0 ),
  155.                                     End,
  156.                                 End,
  157.                             End,
  158.                         End,
  159.                    End ) {
  160.         ULONG   sigs = 0, id;
  161.  
  162.         DoMethod( MainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  163.  
  164.         DoMethod( buttons[ 0 ].Object, MUIM_Notify, MUIA_Selected, FALSE, SpeedBar, 5, MUIM_SpeedBar_DoOnButton, 1, MUIM_Set, MUIA_Selected, FALSE );
  165.         DoMethod( buttons[ 3 ].Object, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  166.  
  167.         DoMethod( buttons2[ 0 ].Object, MUIM_Notify, MUIA_Selected, FALSE, SpeedBar2, 5, MUIM_SpeedBar_DoOnButton, 1, MUIM_Set, MUIA_Selected, FALSE );
  168.         DoMethod( buttons2[ 3 ].Object, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  169.  
  170.         DoMethod( update, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, TAG_USER );
  171.  
  172.         set( MainWin, MUIA_Window_Open, TRUE );
  173.  
  174.         while(( id = DoMethod( AppObj, MUIM_Application_NewInput, &sigs )) != MUIV_Application_ReturnID_Quit ) {
  175.  
  176.                 if( id == TAG_USER ) {
  177.                     struct MUIS_SpeedBarCfg_Config *cfg;
  178.  
  179.                     get( Settings, MUIA_SpeedBarCfg_Config, &cfg );
  180.  
  181.                     set( SpeedBar, MUIA_SpeedBar_ViewMode,     cfg->ViewMode     );
  182.                     set( SpeedBar, MUIA_SpeedBar_Borderless,   ( cfg->Flags & MUIV_SpeedBarCfg_Borderless   ) ? TRUE : FALSE );
  183.                     set( SpeedBar, MUIA_SpeedBar_RaisingFrame, ( cfg->Flags & MUIV_SpeedBarCfg_Raising      ) ? TRUE : FALSE );
  184.                     set( SpeedBar, MUIA_SpeedBar_SmallImages,  ( cfg->Flags & MUIV_SpeedBarCfg_SmallButtons ) ? TRUE : FALSE );
  185.                     set( SpeedBar, MUIA_SpeedBar_Sunny,        ( cfg->Flags & MUIV_SpeedBarCfg_Sunny        ) ? TRUE : FALSE );
  186.  
  187.                     set( SpeedBar2, MUIA_SpeedBar_ViewMode,     cfg->ViewMode     );
  188.                     set( SpeedBar2, MUIA_SpeedBar_Borderless,   ( cfg->Flags & MUIV_SpeedBarCfg_Borderless   ) ? TRUE : FALSE );
  189.                     set( SpeedBar2, MUIA_SpeedBar_RaisingFrame, ( cfg->Flags & MUIV_SpeedBarCfg_Raising      ) ? TRUE : FALSE );
  190.                     set( SpeedBar2, MUIA_SpeedBar_SmallImages,  ( cfg->Flags & MUIV_SpeedBarCfg_SmallButtons ) ? TRUE : FALSE );
  191.                     set( SpeedBar2, MUIA_SpeedBar_Sunny,        ( cfg->Flags & MUIV_SpeedBarCfg_Sunny        ) ? TRUE : FALSE );
  192.                 }
  193.  
  194.             if( sigs ) {
  195.  
  196.                 sigs = Wait( sigs | SIGBREAKF_CTRL_C );
  197.  
  198.                 if( sigs & SIGBREAKF_CTRL_C )
  199.                     break;
  200.             }
  201.         }
  202.  
  203.         MUI_DisposeObject( AppObj );
  204.     }
  205.  
  206.     for( i = 0; i < 4; i++ )
  207.         FreeBrush( Brushes[ i ]);
  208.  
  209.     if( lock )
  210.         UnLock( CurrentDir( olddir ));
  211.  
  212.     CloseLibrary( MUIMasterBase );
  213.  
  214.     return( 0 );
  215. }
  216.